refactor(core): ProcessCtx, grouped match arms, aof clarity - #193
Merged
Conversation
shard.rs
- extract ProcessCtx<'a> struct to replace the 10-parameter signature of
process_message, removing #[allow(clippy::too_many_arguments)]
- call site in run_shard constructs one ProcessCtx per recv iteration;
the drain loop reuses the same ctx via &mut reborrow
- expand dispatch doc comment to clarify it is the hot path
aof.rs
- improve from_bytes doc comment to note CRC responsibility and relation
to to_bytes format
- add inline byte-count comments to the Set, Del/LPop/Persist/Incr,
Expire/Pexpire, and LPush/RPush arms of estimated_size
command.rs
- extract wrong_arity() helper to reduce ProtocolError::WrongArity("X".into())
boilerplate across ~50 parse functions
- add category comment headers to is_write() and command_name() so each
data-type group is immediately visible without reading every arm
kacy
added a commit
that referenced
this pull request
Feb 19, 2026
shard.rs
- extract ProcessCtx<'a> struct to replace the 10-parameter signature of
process_message, removing #[allow(clippy::too_many_arguments)]
- call site in run_shard constructs one ProcessCtx per recv iteration;
the drain loop reuses the same ctx via &mut reborrow
- expand dispatch doc comment to clarify it is the hot path
aof.rs
- improve from_bytes doc comment to note CRC responsibility and relation
to to_bytes format
- add inline byte-count comments to the Set, Del/LPop/Persist/Incr,
Expire/Pexpire, and LPush/RPush arms of estimated_size
command.rs
- extract wrong_arity() helper to reduce ProtocolError::WrongArity("X".into())
boilerplate across ~50 parse functions
- add category comment headers to is_write() and command_name() so each
data-type group is immediately visible without reading every arm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
final pass in the refactoring series, targeting three foundational crates.
no functional changes.
ProcessCtx in shard.rs —
process_messagehad 10 parameters and a#[allow(clippy::too_many_arguments)]suppression. extracted aProcessCtx<'a>struct that groups all per-call mutable state. the callsite in
run_shardconstructs one context per recv iteration and passes&mut ctxto both the initial dispatch and the drain loop, avoiding anyextra allocation. the clippy suppression is gone.
also added a short doc comment to
dispatchclarifying it is the hot pathevery command goes through.
aof.rs doc improvements — expanded the
from_bytesdoc comment toexplain the CRC contract and its relationship to
to_bytes. addedinline byte-count comments to
estimated_sizefor the most commonrecord variants so the arithmetic is self-evident without counting struct
fields mentally.
command.rs readability — extracted
wrong_arity()to replace ~50identical
ProtocolError::WrongArity("CMD".into())expressions across theparser functions. added category comment headers (
// strings,// key lifecycle,// list, etc.) tois_write()andcommand_name()so eachdata-type group is immediately scannable.
what was tested
cargo build --workspace— cleancargo test -p emberkv-core -p ember-protocol -p ember-persistence -p ember-cluster -p ember-server— all passcargo clippy --workspace -- -D warnings— zero warnings